<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>退货查询</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
      <!--搜索开始-->
      <fieldset class="layui-elem-field layuimini-search">
        <legend>搜索信息</legend>
        <div style="margin: 10px 10px 10px 10px">
          <form class="layui-form layui-form-pane" action="" id="searchFrm">
            <div class="layui-form-item">
              <div class="layui-inline">
                <label class="layui-form-label">供应商</label>
                <div class="layui-input-inline">
                  <select name="providerId" class="providerSel">
                    <option value ="">请选择供应商</option>
                  </select>
                </div>
              </div>
              <div class="layui-inline">
                <label class="layui-form-label">商品名称</label>
                <div class="layui-input-inline">
                  <input type="hidden" name="id" />
                  <select name="goodsId" id="data_goodsid" class="goodsSel">
                    <option value ="">请选择商品</option>
                  </select>
                </div>
              </div>
              <div class="layui-inline">
                <label class="layui-form-label">开始时间</label>
                <div class="layui-input-inline">
                  <input type="text" name="startTime" id="startTime" readonly="readonly" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-inline">
                <label class="layui-form-label">结束时间</label>
                <div class="layui-input-inline">
                  <input type="text" name="endTime" id="endTime" readonly="readonly" autocomplete="off" class="layui-input">
                </div>
              </div>
            </div>
            <div class="layui-form-item">
              <div class="layui-block" style="text-align: center;">
                <a class="layui-btn " lay-submit=""  lay-filter="data-search-btn"><label class="layui-icon layui-icon-search"></label>搜索</a>
                <a class="layui-btn layui-btn-warm" onclick="javascript:$('#searchFrm')[0].reset()" lay-filter="data-search-btn"><label class="layui-icon layui-icon-refresh"></label>重置</a>
              </div>
            </div>
          </form>
        </div>
      </fieldset>
      <!--搜索结束-->

      <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

    </div>
</div>

<script src="/lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<script src="/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script src="/lib/common/jquery.cookie.min.js" charset="utf-8"></script>
<script src="/lib/common/common.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table','laydate','layer'], function () {
      var $ = layui.jquery,
          form = layui.form,
          table = layui.table;
      var laydate=layui.laydate;
		  var layer=layui.layer;

      //渲染时间选择器
      laydate.render({
        elem:'#startTime',
        type:'datetime'
      });
      laydate.render({
        elem:'#endTime',
        type:'datetime'
      });

      // 加载查询条件里面的供应商的下拉列表
      $.get(api+"/provider/getAllEnableProvider",function(res){
        var search_providerid=$(".providerSel");
        var html="<option value =''>请选择供应商</option>";
        var data=res.data;
        $.each(data,function(index,item){
          html+="<option value ="+item.id+">"+item.providerName+"</option>"
        });
        search_providerid.html(html);
        form.render("select");
      });

      var goodsCache;
      //加载查询条件里面的商品的下拉列表
      $.get(api+"/goods/getAllEnableGoods",function(res){
        var search_goodsid=$(".goodsSel");
        var html="<option value =''>请选择商品</option>";
        var data=res.data;
        goodsCache = data;
        $.each(data,function(index,item){
          html+="<option value ="+item.id+">"+item.goodsName+"["+item.spec+"]"+"</option>"
        });
        search_goodsid.html(html);
        form.render("select");
      });

      var tableIns = table.render({
        elem: '#currentTableId',
        url: api + '/goodsBack/getByPage',
        method: 'post',
        contentType: "application/json; charset=utf-8",
        toolbar:"#toolBar",
        cellMinWidth: true,
        parseData: function(res){ //res 即为原始返回的数据
          return {
            "code": res.code, //解析接口状态
            "msg": res.msg, //解析提示文本
            "count": res.data.total, //解析数据长度
            "data": res.data.records //解析数据列表
          };
        },
        response:{ // 必须配置，否则不加载数据
            statusName:'code', //规定返回的状态码字段为code
            statusCode:200 //规定成功的状态码味200
        },
        done: function(res, curr, count){
            //如果是异步请求数据方式，res即为你接口返回的信息。
            //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
            // console.log(res);
            //得到当前页码
            // console.log(curr); 
            //得到数据总量
            // console.log(count);
        },
        cols: [[
            {type: "checkbox", width: 50, fixed: "left"},
            {type: "numbers", width: 40, title: '序号', fixed: "left"},
            {field: 'id', width: 80, title: 'ID', hide: true},
            {field: 'goodsName', width: 120, title: '商品'},
            {field: 'providerName', width: 120, title: '供应商'},
            {field: 'payType', width: 100, title: '支付方式'},
            {field: 'backTime', width: 200, title: '退货时间'},
            {field: 'number', width: 120, title: '退货数量'},
            {field: 'backPrice', width: 120, title: '退货价格'},
            {field: 'operatePerson', width: 100, title: '操作员'},
            {field: 'remark', width: 200, title: '备注'}
        ]],
        limits: [10, 15, 20, 25, 5],
        limit: 15,
        page: true
      });

      // 监听搜索操作
      form.on('submit(data-search-btn)', function (data) {
        //执行搜索重载
        table.reload('currentTableId', {
          page: {
            curr: 1
          },
          where: {
            queryParams: {
              "providerId": data.field.providerId,
              "goodsId": data.field.goodsId,
              "startTime": data.field.startTime,
              "endTime": data.field.endTime
            }
          },
          async: true
        }, 'data');
        return false;
      });
    });
</script>
<script>

</script>

</body>
</html>